<template>
  <div>
    <h1>这是要写点击变色的页面</h1>
    <ul>
      <li
        v-for="i in 10"
        :key="i"
        @click="change(i)"
        :class="{ active: flag == i }"
      >
        <!-- 如果是当前点的这个就变颜色 -->
        {{ i }}
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      flag: 1,
    };
  },
  methods: {
    change(i) {
      console.log(i);
      this.flag = i;
      //把当前点击的是谁保存下来
    },
  },
};
</script>
<style lang="scss">
.active {
  background: greenyellow;
}
</style>
